package com.whut.utils;

import cn.hutool.core.text.StrFormatter;
import com.alibaba.druid.sql.visitor.functions.Char;

import static org.springframework.util.StringUtils.isEmpty;

/**
 * @author ：xiaojun
 * @date ：Created in 2021/3/9 16:50
 * @description：字符串工具类
 * @modified By：
 * @version: $
 */
public class HbyrStringUtils extends org.springframework.util.StringUtils{

    public static String format(String template,Object... params){
        if(isEmpty(params)|| isEmpty(template)){
            return template;
        }
        return StrFormatter.format(template,params);
    }

    /**
     *
     * @param str
     * @param symbol
     * @return 返回擦除指定符号的字符串
     */
    public static String  wipeOffSymbol(String str,char symbol){
        StringBuilder stringBuilder=new StringBuilder(str.length());
        if(isEmpty(str)){
            throw new NullPointerException();
        }
        for(char c:str.toCharArray()){
            if(symbol!=c){
                stringBuilder.append(c);
            }
        }
        return stringBuilder.toString();
    }

    /**
     *
     * @param str
     * @param oldSymbol
     * @param newSymbol
     * @return 返回符号替换的字符串
     */
    public static String replaceSymbol(String str,char oldSymbol,char newSymbol){
        return str.replace(oldSymbol,newSymbol);
    }
}
